package cn.usian.order.service.impl;

import cn.usian.order.fegin.UserFegin;
import cn.usian.order.mapper.OrderMapper;
import cn.usian.order.pojo.Order;
import cn.usian.order.pojo.User;
import cn.usian.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 06 05 16 10
 **/
@Service
public class OrderServiceImpl implements OrderService {

   @Autowired
   OrderMapper orderMapper;

   @Autowired
   RestTemplate restTemplate;

    @Autowired
    UserFegin userFegin;
    @Override
    public Order getOrderById(Integer id) {
        Order order = orderMapper.getOrderById(id);
//        String url = "http://localhost:8082/v1/api/user/getUserById?id="+order.getUserId();
//        User user = restTemplate.getForObject(url, User.class);
        User user = userFegin.getUserById(order.getUserId());

        order.setUserInfo(user);
        return order;
    }
}
